package com.zhn.resourcej.web.response;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class Result {
    private int code;
    private String msg;
    private Object data;
    private long total;
    public static Result success(String msg,Object data) {
        return new Result().setCode(0).setMsg(msg).setData(data);
    }
    public static Result success(String msg,Object data,long total) {
        return new Result().setCode(0).setMsg(msg).setData(data).setTotal(total);
    }
    public static Result success(Object data) {
        return new Result().setCode(0).setData(data).setMsg("成功");
    }
    public static Result success(String msg) {
        return new Result().setCode(0).setMsg(msg);
    }

    public static Result fail(String msg) {
        return new Result().setCode(-999).setMsg(msg);
    }

    public static Result fail(int code,String msg) {
        return new Result().setCode(code).setMsg(msg);
    }
}
